package com.wxl.common.room.entity;

import androidx.room.Entity;
import androidx.room.Ignore;

import com.wxl.common.util.StringUtils;

import java.io.Serializable;

/**
 * 雷管类
 */
@Entity(tableName = "leiguan")
public class LeiGuanEntity extends LeiGuanBean implements Serializable {



    @Ignore
    public int editor;//修改状态,0:正常，1:修改延时 2:插入
    @Ignore
    public int editorIndex;//修改脚标
    @Ignore
    public String sort;
    @Ignore
    public String kong;

    public int isDelayPlan;//延时方案列表0：正常 1：延时方案

    @Ignore
    public int total;


    public static LeiGuanEntity parse(String data){
        LeiGuanEntity item = new LeiGuanEntity();
        item.serialNumber = Integer.valueOf(data.substring(12, 16), 16).toString();
        item.UID = data.substring(20, 36);
        item.delay = Integer.valueOf(data.substring(44, 48), 16).toString();
        item.holeNumber = data.substring(48, 52);
        item.state = StringUtils.HexToBin8(data.substring(52, 54));
        item.total = Integer.valueOf(data.substring(16, 20), 16);
        return item;
    }


    public static LeiGuanEntity parseDetonator(String data){
        LeiGuanEntity item = new LeiGuanEntity();
        item.serialNumber = Integer.valueOf(data.substring(12, 16), 16).toString();
        item.UID = data.substring(16, 32);
        item.delay = Integer.valueOf(data.substring(32, 36), 16).toString();
        item.holeNumber = data.substring(36, 40);
        return item;
    }
}
